{% extends "main.html" %}

{% block head %}
    {{ super() }}
{% endblock %}


{% block title %}
    Ranking - {{ asn }}
{% endblock %}

{% block scripts %}
    {{ super() }}
    <script src='{{ url_for('static', filename='linegraph.js') }}'></script>
    <script>linegraph('/json/asn_history');</script>
{% endblock %}

{% block content %}
  <center>
      <h1>Ranking - {{asn}}</h1></br></br>
      <button data-html="true" type="button" class="btn btn-secondary" data-container="body"
         data-toggle="popover" data-placement="bottom"
                               data-content="<center><b>sum</b>(IP * weight of the list) </br><hr><b>sum</b>(IP in the prefix)</center>">
        <h4>How is this ranking computed?</h4>
     </button>
  </center>
  {% include ['top_forms.html'] %}
  <table class="table">
      <tr>
          <th>Timestamp</th>
          <th>ASN Description</th>
      </tr>
      {% for timestamp in asn_descriptions.keys()|sort %}
        <tr>
            <td>{{ timestamp }}</td>
            <td>{{ asn_descriptions[timestamp] }}</td>
        </tr>
      {% endfor %}
  </table>
  <table class="table">
      <tr>
          <th>Prefix</th>
          <th>Rank</th>
      </tr>
      {% for prefix, rank in ranks %}
        <tr>
            <td><a href="{{ url_for('asn_details', asn=asn, prefix=prefix) }}">{{ prefix }}</a></td>
            <td>{{ rank }}</td>
        </tr>
      {% endfor %}
  </table>
  <canvas width="960" height="500"></canvas>
  {% if prefix_ips %}
  <table class="table">
      <tr>
          <th>IP</th>
          <th>Source(s)</th>
      </tr>
      {% for ip, sources in prefix_ips %}
        <tr>
            <td>{{ ip }}</td>
            <td>{{ ', '.join(sources) }}</td>
        </tr>
      {% endfor %}
  </table>
  {% endif %}
{% endblock %}
